package com.srwl.mytx.widget.chatRow;

import android.text.SpannableString;
import android.text.style.ImageSpan;
import android.view.View;
import android.widget.TextView;

import com.srwl.mytx.Constant;
import com.srwl.mytx.R;
import com.srwl.mytx.utils.MoonUtils;

import butterknife.ButterKnife;

public class ChatRowText extends BaseChatRow {


    private TextView contentView;

    public ChatRowText(View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);
    }

    @Override
    protected void onInflateView() {

    }

    @Override
    protected void onFindViewById(View itemView) {
        contentView = itemView.findViewById(R.id.tv_chat_content);
    }

    @Override
    public void onSetUpView() {
//        Spannable span = EmojiManager.getSmiledText(context, message.getContent());
//        // 设置内容
//        contentView.setText(span, BufferType.SPANNABLE);

       // MoonUtils.identifyFaceExpression(context, contentView, message.getContent(), ImageSpan.ALIGN_BOTTOM, 1);
        SpannableString spannableString = MoonUtils.replaceEmoticonsAndHighlight(context, message.getContent(), 0.6f, ImageSpan.ALIGN_BOTTOM, message.getHighlightKeyWord(), context.getResources().getColor(R.color.holo_blue_bright));
        contentView.setText(spannableString);
        handleTextMessage();
    }


    protected void handleTextMessage() {


        if (!isSendMessage && message.getReadState() == Constant.MESSAGE_READ_STATE_UNREAD && chatRowCallBack != null) {

            //  message.setMsgReadStatus(2);
            chatRowCallBack.onMessageRead(message);

        }
    }

    @Override
    protected void onUpdateView() {

    }

    @Override
    protected void onBubbleClick() {

    }


}
